from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from time import sleep


import sys

sys.path.append(r'..')
from web_base.base_page import BasePage
from page_object.login_page import LoginPage

class AssetPage(BasePage):
    url = r'/bsams/front/asset/asset_list.do'

    # 查询定位
    add_ben_loc = (By.XPATH, '//*[@id="leftmenu_asset_manage"]/div[1]/a/img')
    add_status_loc = (By.ID, 'status')
    add_title_loc = (By.ID, 'title')
    add_ok_loc = (By.CLASS_NAME, 'search_button')

    def query_location(self,text,status):
        self.open()
        self.ele_click(self.add_ben_loc)
        sleep(2)
        self.ele_select(self.add_status_loc, status)
        self.input_ele(self.add_title_loc,text)
        sleep(2)
        self.ele_click(self.add_ok_loc)
        sleep(2)

if __name__ == '__main__':
    text = '赵'
    status = '使用'

    chrome_location = r'D:\测试工具\Win_x64_1135105_chrome-win\chrome-win\chrome.exe'
    options = webdriver.ChromeOptions()
    options.binary_location = chrome_location
    driver_location = r'D:\测试工具\pythan\chromedriver.exe'
    service = Service(driver_location)

    driver=webdriver.Chrome(options=options,service=service)

    login_page = LoginPage(driver)
    login_page.login()

    asset_page = AssetPage(driver)
    asset_page.query_location(text,status)
    driver.quit()